package com.thingsgrid.device.mapper;

import com.thingsgrid.device.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * 功能说明：产品mapper
 *
 * @author 李龙飞
 * @since 2019/9/18 15:38
 */
@Repository("productMapper")
public class ProductMapper {
	@Autowired
	private MongoTemplate mongoTemplate;

	/**
	 *说明：根据产品ID查询产品信息
	 *@author lilongfei
	 *@since 2019/9/18 15:39
	 */
	public Product getProductById(String productId){
		return mongoTemplate.findById(productId,Product.class,"product");
	}

	/**
	 *说明：获取产品列表
	 *@author lilongfei
	 *@since 2019/9/25 15:09
	 */
	public List<Product> getProductList(){
		return mongoTemplate.findAll(Product.class,"product");
	}

}
